﻿<%@ Control Language="C#" AutoEventWireup="false" CodeFile="ToDo.ascx.cs" Inherits="Controls_ToDo" %>
<style>
cool\:tip{behavior: url(/Include/HTC/cooltip_js.htc)}
TABLE.GridView.Bridge TH INPUT.Filter{	text-transform:uppercase;	behavior1: url(/Include/HTC/TipMe.htc)}
CAPTION {BEHAVIOR: url(/Include/HTC/Toggle.htc);COLOR:navy;FONT-WEIGHT:bold}
TABLE.GridView TD.BorderRight{	border-right-width:1px;	border-right-color: Black}
TABLE.GridView TD.NextDue{background-color:#F5F5F5}
TABLE.GridView TD.Red{background-color:#FFE5E5}
TABLE.GridView TD.RedDark{color:#B80000}
TABLE.GridView TD.GreenDark{color:#006600}
TABLE.GridView TD.U A{color:black;text-decoration:none}
TABLE.GridView TD.U A.Bold{font-weight:bold}
TABLE.GridView TR TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
TABLE.Big TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
.Big{font-size:<%=ddlFontSize.SelectedValue%>}
.button INPUT {overflow:visible;padding:0px 3px;vertical-align:middle}
.button SELECT {vertical-align:middle}
SPAN.CheckBox INPUT{border:none;vertical-align:middle}
</style>
<div id="divGrid"><!-- Bridge -->
<asp:UpdatePanel ID="upBridge" UpdateMode="Always" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="ddlFontSize" />
</Triggers>
<ContentTemplate>
<span title="Change Font Size">
<asp:DropDownList ID="ddlFontSize" style="background-color:#D1FFDC;vertical-align:middle" AutoPostBack="true" runat="server">
<asp:ListItem Text="100%" Value="100%" />
<asp:ListItem Text="120%" Value="120%" Selected="True" />
<asp:ListItem Text="140%" Value="140%" />
<asp:ListItem Text="160%" Value="160%" />
</asp:DropDownList></span>
<asp:ObjectDataSource ID="dsUsersCached" SelectMethod="UserList" runat="server" />
<asp:DropDownList id="ddlUsers" DataSourceID="dsUsersCached" DataTextField="DisplayName" DataValueField="UserName" style="background-color:#FFE8A3;vertical-align:middle" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
>
<%--		 OnDataBound="ddlUsers_DataBound" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged"--%>
<asp:ListItem Text ="All Users" Value="*"></asp:ListItem>
<asp:ListItem Text ="Self" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlIsTask" style="background-color:#B3ECFF;vertical-align:middle" AutoPostBack="true" runat="server">
	<asp:ListItem Text="Active & Inactive Tasks" Value=""></asp:ListItem>
	<asp:ListItem Text="Active Tasks" Value="137" Selected="True"></asp:ListItem>
	<asp:ListItem Text="Inactive Tasks" Value="113"></asp:ListItem>
</asp:DropDownList>
<DS:NoteActionCodesWithTaskDataSource id="dsNAC_T" runat="server" />
<asp:DropDownList ID="ddlTasks" style="background-color:#FFD1C2;vertical-align:middle" DataSourceID="dsNAC_T" DataTextField="Name" DataValueField="ID" AppendDataBoundItems="true" AutoPostBack="true" runat="server">
	<asp:ListItem Value="" Text="All Tasks" Selected="True"></asp:ListItem>
</asp:DropDownList>
<div ID="pnlFilter" runat="server"></div>
<DS:NoteTasksDataSource ID="ds" CacheKeyDependency="ds" CacheDuration="Infinite" EnableCaching="true" runat="server" />
<UI:GridViewMB ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds" style="width:100%" ShowDelete="false"
	AllowSorting="True"	DataKeyNames="ID,LoanID,UsixID,CompanyID" EnableViewState="false" ShowFooter="false" EmptyDataRowStyle-Font-Bold="true" EmptyDataText="No comments"
	RowStyle-VerticalAlign="Top" OnRowClick="void(LoanID)" RowStyle-CssClass="Notes"
	>
	<Columns>
<asp:TemplateField HeaderText="LoanID" SortExpression="LoanID">
<ItemTemplate>
	<span style="cursor:hand;font-weight:bold;color:Navy" title='Click to open <%#Eval("LoanID")%>'
		onclick='<%#ShowApplicantJS(Eval("LoanID"))%>'><%#Eval("LoanID")%>
	</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Note" SortExpression="Note">
	<ItemStyle CssClass="noOver" />
	<ItemTemplate>
		<fieldset><legend style="behavior: url(/Include/HTC/Toggle.htc)" state="+"><asp:Label Text='<%#Lib.Substring(Eval("Note"),30)%>' ToolTip='<%#Eval("Note")%>' runat="server" /></legend>
		<pre style="font-size:125%"><%#(Eval("Note")+"").Length>0?Lib.FormatNote(Eval("Note")+"",60):""%></pre>
		</fieldset>
	</ItemTemplate>
	<EditItemTemplate><asp:TextBox TextMode="MultiLine" style="width:100%;overflow:visible;font-family:Monospace;white-space:pre" Text='<%# Bind("Note") %>' ID="txtNote" runat="server" /></EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type" SortExpression="NoteType">
	<ItemTemplate><asp:Label ToolTip='<%#Eval("NoteType")%>' Text='<%#Eval("NoteTypeNick")%>' runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Actn" SortExpression="NoteActionCode">
	<ItemTemplate><asp:Label ToolTip='<%#Eval("NoteActionCode")%>' Text='<%#Eval("NoteActionCodeNick")%>' runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Result" SortExpression="StatusNick">
	<ItemTemplate>
		<DS:StateFlowNextStatesDataSource ID="dsSN_Edit" StateFromID='<%#int.Parse("0"+Eval("StatusID"))%>' runat="server" />
		<asp:DropDownList SelectedValue='<%#Bind("StatusID")%>' onclick="event.cancelBubble=true;" onchange="if(!confirm('Change status?'))return;" NoteID='<%#Eval("ID")%>' ID="selStatusID" DataSourceID="dsSN_Edit" DataTextField="StateTo" DataValueField="StateToID" AutoPostBack="true" OnSelectedIndexChanged="UpdateNoteStatus" runat="server"/>
	</ItemTemplate>
	<EditItemTemplate>
	</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Due" SortExpression="DateDue">
	<ItemTemplate><%#Eval("DateDue", "{0:MM/dd/yy HH:mm}")%></ItemTemplate>
	<EditItemTemplate><asp:TextBox Text='<%# Bind("DateDue") %>' ID="txtDateDue" runat="server" /></EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" SortExpression="StatusDate">
	<ItemTemplate><%#Eval("StatusDate", "{0:MM/dd/yy HH:mm}")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Request By" SortExpression="NoteUser">
	<ItemTemplate><%#Eval("NoteUser") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Assigned To" SortExpression="DateDueBy">
	<ItemTemplate><%#Eval("DateDueBy")%></ItemTemplate>
	<EditItemTemplate>
				<asp:DropDownList SelectedValue='<%#Bind("DateDueBy")%>' ID="dsDueDateBy"  DataSourceID="dsLoginsDataSource" DataTextField="DisplayName" DataValueField="sAMAccountNameLower" AutoPostBack="false" runat="server"  AppendDataBoundItems="true"
						 style="vertical-align:middle">
						 <asp:ListItem></asp:ListItem>
			</asp:DropDownList>
			<DS:LoginsDataSource ID="dsLoginsDataSource" runat="server" />
	</EditItemTemplate>
</asp:TemplateField>
	</Columns>
</UI:GridViewMB>
</ContentTemplate></asp:UpdatePanel>
</div>
<asp:UpdatePanel ID="upColl" UpdateMode="Always" runat="server"><ContentTemplate>
<UI:CollectionInfo ID="CollectionInfo" runat="server" />
</ContentTemplate></asp:UpdatePanel>

<loan:Payments runat="server" />
<UI:Notes ID="Notes" runat="server" />
<DS:NoteTypesDataSource ID="dsNT" runat="server" />
<cool:tip delay="700" avoidMouse="true" duration="60"></cool:tip>
<script>
window.onerror = function(){return event.returnValue = true;}
pageLoads.push(GVX_InitHeader);
setInterval(function(){showExpiration();},1*1000);
function InitHeader(){
	var inputs = divGrid.all.tags("INPUT");
	for( var i=0 ; i < inputs.length; i++ ){
		if( inputs[i].type != "text" )continue;
		inputs[i].onkeypress = null;
		inputs[i].delay = 700;
		inputs[i].coolTip = inputs[i].title.replace(/\r\n/g,"<br>");
		inputs[i].title = "";
		inputs[i].onmouseover = function(){
			event.srcElement.style.position = "relative";
			event.srcElement.style.zIndex=1000;
			event.srcElement.style.backgroundColor="white";
			showTip(this);
		};
		inputs[i].onmouseout = function(){
			event.srcElement.style.position = "";
			event.srcElement.style.zIndex=null;
			event.srcElement.style.backgroundColor="";
		};
	}
}
function showTip(el){
//el.coolTip = "Dimok";
	var tip = ((el.coolTip||"").match(/.+?<br>(.+)/)||new Array("",""))[1];
	el.coolTip = (el.value.fontcolor("navy").bold() + "<br>" + tip.replace(/(XXX|YYY|ZZZ)/g,"$1".fontcolor("#B80000").bold()));//.fontsize(3);
}
function showActivity(){
	showModelessDialog("/manager/collection/activity.aspx");
}
function showExpiration(){
	if( typeof(tdCollectionExpiration) == 'undefined' )return;
	WSA.Admin.GetLockInfo(cb);
	function cb(result){
		var rs = getRSFromDS(result,"Locks");
		var expMessage = "Session Expired".bold().fontcolor("maroon");
		if( rs != null ){
			var expDate = new Date("1/1/1900 "+rs("ExpiresIn").value);
			if( expDate.getMinutes() == 0 && expDate.getSeconds() <= 60 ){
				if( !showExpiration.expPopupShown ){
					showExpiration.expPopupShown = true;
					return refreshExpiration();
				}					
			}else showExpiration.expPopupShown = false;
			expMessage = "Expires In".bold()+"<br>"+rs("ExpiresIn");
		}
		try{
			if( !tdCollectionExpiration.onclick )tdCollectionExpiration.onclick = function(){btnRefresh().click();}
			tdCollectionExpiration.innerHTML = expMessage;
		}catch(e){status = e.description;}
	}
}
function refreshExpiration(){
	if( !confirm("You have less then a minute before session for current Loan expires.\nDo you wish to prolong it?" ) )return false;
		btnRefresh().click();
		true;
}
</script>
<?XML:NAMESPACE PREFIX="COOL" />
